#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

//返回布尔值的一元函数是谓词 这种函数可供STL算法用户判断
template<typename T>
struct IsMutiple //判断是否是初始值的倍数
{
    T Divistor;
    IsMutiple(const T& divistor)
    {
        Divistor = divistor;
    }
    bool operator()(const T& value1) const
    {
        return (value1/Divistor >= 1 && value1 % Divistor == 0);
    }
};
typedef vector<int, int>vector_DESC;
int main(int argc, char const *argv[])
{
    vector<int>myvector;
    map<int, int>mymap;
    int s[5] = {2,5,9,12,15};
    for(size_t i = 0; i < 5; i++)
    {
        myvector.push_back(i);
        mymap.insert(make_pair(i, s[i]));
    }
    for_each(myvector.begin(), myvector.end(),[](int& ele){ //for_each只能用于内存地址连续的数据类型?
        cout << ele << endl;
    });
    for(map<int, int>::iterator mapIterator = mymap.begin(); mapIterator != mymap.end(); ++mapIterator)
    {
        cout << mapIterator->second << endl;
    }
    cout << "---------------------" << endl;
    auto iElement = find_if(myvector.begin(), myvector.end(), IsMutiple<int>(3));
    if(iElement != myvector.end())
    {
        cout << *iElement << endl;
    }
    return 0;
}
